<template>
	
	<form @submit="submit" :data-action="`/api/monitoringFactor/save?stationId=${param.id}`">
			
			<!-- <view class="fixAuto bb middle">
				<view class="w100">
					设备监测因子
				</view>
				<view>
					<input type="text" name="x.factor|设备监测因子|0~50" placeholder="请输入设备监测因子">
				</view>
			</view> -->
			
			<choosePicker title="监测因子" :list="factorList" :index="factorIndex" name='x.factor|设备监测因子|0~50' @factorChanged="factor=$event" @change="factorIndex=$event.index"></choosePicker>
			<input type="text" name='x.factor|设备监测因子|0~50'  v-model="factor" style="display: none;">
			
			<view class="fixAuto bb middle">
				<view class="w100">
					量程
				</view>
				<view>
					<input type="text" name="x.range|量程|0~200" placeholder="请输入量程">
				</view>
			</view>
			<view class="fixAuto bb middle">
				<view class="w100">
					限值
				</view>
				<view>
					<input type="text" name="x.limit|限值|0~200" placeholder="请输入限值">
				</view>
			</view>
			<view class="fixAuto bb ">
				<view class="w100">
					验收时间
				</view>
				<view class="father">
					<view class="flex " :class="acceptanceTime?'':'rt'">
						<view :class="acceptanceTime?'black':'gray'">
							{{acceptanceTime?acceptanceTime:'请选择'}}
							<input type="text" name="x.acceptanceTime|验收时间" v-model="acceptanceTime" style="display: none;">
						</view>
						<view class="sIcon-arrowRight fz14 grey pl10"></view>
					</view>
					<view class="abs op0">
						<picker mode="date" @change="acceptanceTime = $event.detail.value">
							<view>验收时间</view>
						</picker>
					</view>
				</view>
			</view>
			
			<view class="fixAuto bb ">
				<view class="w100">
					联网时间
				</view>
				<view class="father">
					<view class="flex " :class="networkingTime?'':'rt'">
						<view :class="networkingTime?'black':'gray'">
							{{networkingTime?networkingTime:'请选择'}}
							<input type="text" name="x.networkingTime|联网时间" v-model="networkingTime" style="display: none;">
						</view>
						<view class="sIcon-arrowRight fz14 grey pl10"></view>
					</view>
					<view class="abs op0">
						<picker mode="date" @change="networkingTime = $event.detail.value">
							<view>联网时间</view>
						</picker>
					</view>
				</view>
			</view>
			
			
			<view class="plr100 pd30">
				<button form-type="submit" class="btn block rds23">
					保存记录
				</button>
			</view>
		</form>

	</layout>
</template>

<script>
	export default {
		data() {
			return {
				// factorList:["二氧化硫","氮氧化物","氧","一氧化碳","氯化氢","氟化物","温度","压力","流速","湿度","其他"],
				factorList:[],
				factorIndex:0,
				factor:'',
				param:{id:"",type:1} ,
				acceptanceTime:"",
				networkingTime:""
			}
		},
		onLoad(params) {
			this.param = params ;
			// if(this.param.type == 1){
			// 	this.factorList = ["COD","PH","氨氮","总磷","总氮","流量","其他"] ;
			// }
			this.getOptions();
		},
		methods: {
			
			getOptions : function(e){
				var data = {
					stationId : this.param.id 
				} ;
				this.kit.get("/api/quipment/options",data,res => {
					res.list.push("其他");
					this.factor = res.list.length > 1 ? res.list[0] : "" ;
					this.factorList = res.list ;
				});
			},
			
			submit:function(e){
				this.form.submit(e , this.success);
			},
			
			success:function(e){
				this.kit.goSuccessBack("保存成功");
			}
		}
	}
</script>
<style>
	page{
		background-color: #fff;
	}
</style>